package cn.iocoder.yudao.module.iot.controller.admin;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.iot.dal.dataobject.IotDataBridgeDO;
import cn.iocoder.yudao.module.iot.service.IotDataBridgeService;
import org.springframework.web.bind.annotation.*;
import jakarta.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/api/iot/data-bridge")
public class IotDataBridgeController {
    @Resource
    private IotDataBridgeService dataBridgeService;

    @PostMapping("/create")
    public CommonResult<Long> create(@RequestBody IotDataBridgeDO dataBridge) {
        return CommonResult.success(dataBridgeService.createDataBridge(dataBridge));
    }

    @PutMapping("/update")
    public CommonResult<Boolean> update(@RequestBody IotDataBridgeDO dataBridge) {
        dataBridgeService.updateDataBridge(dataBridge);
        return CommonResult.success(true);
    }

    @DeleteMapping("/delete/{id}")
    public CommonResult<Boolean> delete(@PathVariable Long id) {
        dataBridgeService.deleteDataBridge(id);
        return CommonResult.success(true);
    }

    @GetMapping("/{id}")
    public CommonResult<IotDataBridgeDO> get(@PathVariable Long id) {
        return CommonResult.success(dataBridgeService.getDataBridge(id));
    }

    @GetMapping("/list")
    public CommonResult<List<IotDataBridgeDO>> list() {
        return CommonResult.success(dataBridgeService.getDataBridgeList());
    }
} 